package com.zc.dto;

public class PageDto {
    private int pageNow = 1;//当前页数
    private int pageSize = 10;//每页显示记录的条数
    private int totalCount;//查询条数
    private int totalPageCount;//总的页数
    private int startPage;//开始的位置,从0开始;


    public int getPageNow() {
        return pageNow;
    }



    public void setPageNow(int pageNow) {
        this.pageNow = pageNow;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPageCount() {
        totalPageCount = totalCount / pageSize;
        return totalCount%pageSize == 0 ? totalPageCount : (totalPageCount+1);
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public int getStartPage() {
        return pageSize * (pageNow -1);
    }

    public void setStartPage(int startPage) {
        this.startPage = startPage;
    }


    public PageDto() {
    }

    public PageDto(int pageNow, int pageSize, int totalCount) {
        this.pageNow = pageNow;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.totalPageCount = this.getTotalPageCount();
        this.startPage = this.getStartPage();
    }

    @Override
    public String toString() {
        return "PageDto{" +
                "pageNow=" + pageNow +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", totalPageCount=" + totalPageCount +
                ", startPage=" + startPage +
                '}';
    }
}
